package com.common.server.enums;

/**
 * ClassName: LicenseStatusEnum
 * Package: com.common.server.enums
 * Description:
 *
 * @Author Memory
 * @Create 2024/12/31 13:31
 * @Version 1.0
 */

import lombok.Getter;

/**
 * 证书状态枚举
 */
@Getter
public enum LicenseStatusEnum {
    VALID(0, "生效中"),
    EXPIRED(1, "已过期"),
    REVOKED(2, "已撤销");

    private final int value;
    private final String text;

    LicenseStatusEnum(int value, String text) {
        this.value = value;
        this.text = text;
    }

    /**
     * 判断证书状态
     *
     * @param value 接口状态
     * @return 存在与否
     */
    public static LicenseStatusEnum getEnumByValue(Integer value) {
        if (value == null) {
            return null;
        }
        LicenseStatusEnum[] values = LicenseStatusEnum.values();
        for (LicenseStatusEnum licenseStatusEnum : values) {
            if (licenseStatusEnum.getValue() == value) {
                return licenseStatusEnum;
            }
        }
        return null;
    }
}
